import path from "path"
import { terser } from "rollup-plugin-terser"
import { nodeResolve } from "@rollup/plugin-node-resolve"
import commonjs from "@rollup/plugin-commonjs"
import { babel } from "@rollup/plugin-babel"
import json from "@rollup/plugin-json"
import alias from "@rollup/plugin-alias"

const pathResolve = p => path.resolve(__dirname, p)

export default {
  // external: [/node_modules/],
  input: "./src/index.js",
  output: [
    {
      file: "dist/bundle.js",
      format: "umd",
      name: "ScrewAxios",
    },
    {
      file: "dist/bundle.es.js",
      format: "es",
    },
    {
      file: "dist/bundle.min.js",
      format: "umd",
      name: "ScrewAxios",
      plugins: [terser()],
    },
  ],
  plugins: [
    alias({
      entries: [{ find: "@", replacement: pathResolve("src") }],
    }),
    nodeResolve({
      preferBuiltins: true,
      browser: true,
      mainFields: ["jsnext"],
    }),
    commonjs(),
    json(),
    babel({
      exclude: "node_modules/**",
      babelHelpers: "bundled",
    }),
  ],
}
